#ifndef _TODOTASK_H
#define _TODOTASK_H
#include "Message.h"
#include "TcpConnection.h"
#include "login_context.h"
#include "MySQLClient.h"
#include <string>
using std::string;
// 登录阶段一，数据包中存放用户名
class UserLoginSection1
{
    friend class UserLoginSection2;

public:
    UserLoginSection1(TcpConnectionPtr conn, const Packet &packet, LoginContext &context)
        : _conn(conn), _packet(packet), _context(context) {}
    void process();

private:
    void getsetting(string &s, const char *password);

private:
    TcpConnectionPtr _conn;
    Packet _packet;
    LoginContext &_context;
};
// 登录阶段二，数据包中存放的是密文
class UserLoginSection2
{
public:
    UserLoginSection2(TcpConnectionPtr conn, const Packet &packet, LoginContext &context)
        : _conn(conn), _packet(packet), _context(context) {}
    void process();

private:
    Packet _packet;
    TcpConnectionPtr _conn;
    LoginContext &_context;
};
// 用户注册的第一阶段
class UserRegister1
{
public:
    UserRegister1(TcpConnectionPtr conn, const Packet &packet, LoginContext &context)
        : _conn(conn), _packet(packet),_context(context) {}
    void process();
    string generateSalt(int length);

private:
    Packet _packet;
    TcpConnectionPtr _conn;
    LoginContext &_context;
};
class UserRegister2
{
public:
    UserRegister2(TcpConnectionPtr conn, const Packet &packet, LoginContext &context)
        : _conn(conn), _packet(packet),_context(context) {}
    void process();

private:
    Packet _packet;
    TcpConnectionPtr _conn;
    LoginContext &_context;
};
#endif
